When Vampires Attack
====================

A small mod that makes citizens in a village or city run indoors during a random vampire attack. This includes eclipse attacks as well.

This was born out of frustration at seeing the citizens all trying to be a hero and rushing headlong to their doom attacking master vampires. Instead, the citizens will run to safety like smart people should when faced with the horrors of the undead. NPCs who live in the attack location who own a home there will retreat to it. If the attack location has an inn, NPCs who don't live there will flee to the inn, along with any NPCs who live outdoors. If no inn is present the game picks a random interior from the surrounding area and those NPCs will flee there instead.

This should work for any NPCs added by mods as well, up to a limit of 150 in the area. After that, they're on their own. The NPCs chosen are first come, first serve by the game engine. 

Guards, members of The Companions, Vigilants of Stendaar, the Dawnguard, and the player's followers/teammates will not run, they will stand and fight. Farm animals will not run either, because they're stupid. That includes your horse.

Download Locations
==================

AFK Mods             - http://afkmods.iguanadons.net/index.php?/files/file/544-when-vampires-attack/
Steam Workshop       - http://steamcommunity.com/sharedfiles/filedetails/?id=114273579
Skyrim Nexus         - http://www.nexusmods.com/skyrim/mods/28235/
TES Alliance         - http://tesalliance.org/forums/index.php?/files/file/1404-when-vampires-attack/
Dark Creations       - http://www.darkcreations.org/forums/files/file/544-when-vampires-attack/
The Assimilation Lab - http://www.theassimilationlab.com/forums/files/file/858-when-vampires-attack/

Installation Requirements
=========================

Official Skyrim patch 1.9.32.0.8 or greater.
Official Dawnguard DLC.

Installation - Wrye Bash BAIN
=============================

Drop the archive into your Skyrim Mods\Bash Installers folder, then install as usual.
Make sure the mod is active in the Wrye Bash mods tab.

Installation - Nexus Mod Manager
================================

Use the "Download with Manager" button on the When Vampires Attack page at Skyrim Nexus. The installer should take care of things from there.
Then simply make sure NMM has the mod activated.

Installation - Manual
=====================

Drop the When Vampires Attack.esp and When Vampires Attack.bsa files into your Data folder.
Activate the mod using whatever management tool suits you.

Uninstall
=========

Remove the two files from the Data folder.

This mod has no continually updating scripts so the contamination of your save game will be minimal.

Known Issues
============

A bad navmesh in an attack location can severely impact the ability of NPCs to clear the area. If you see any getting stuck and acting like they can't move, this is probably why. If the area is modified, you'll need to take this up with the author(s) of the mod(s) affecting the area. If the area is NOT modified (ie: totally vanilla) then please report such events so that I can pass them along to the USKP tracker to investigate.

If an attack location has more than 150 NPCs to protect, only the first 150 will fill the quest aliases. After that, any leftovers are on their own and can still be killed! 150 NPC slots is enough to protect all of Solitude running Open Cities Skyrim with 60 slots left open. That ought to be more than enough. If it's not, there's nothing more I can do. Too many aliases in a quest leads to severe degradation in performance. I had to strike a balance somewhere.

The alias fill casts a very wide net, do not be surprised if you see Khajiit from the caravans come in to seek shelter from an attack, or other NPCs who commonly live outside of a major city.

Compatibility
=============

Fully compatible with the Unofficial Dawnguard Patch.

Tested and confirmed to work with Open Cities Skyrim.

Mods for Dawnguard which edit the following scripts will not be compatible unless patched:

DLC1RadiantDisguisedVampireLordScript.psc
DLC1EclipseAttackScript.psc

How to Make it Work With Your Mod
=================================

In order for the system in place to work with a mod added location, a few things need to be set up.

1. A location should be established with the keyword LocTypeHabitation.
2. This location requires a marker with its location reference type set to LocationCenterMarker. This works best outdoors as close to the geographic center of your area as possible.
3a. If your settlement has an inn, you can have that become usable by flagging it as LocTypeInn. It must be set as a child location of the location in step 1.
3b. If you do not hav an inn, then you need at least one interior with the LocTypeDwelling keyword set. It must be a child location of the location from step 1.
4. In the interior from step 3, a marker with its location reference type set to LocationCenterMarker must be placed. This is the target the AI packs will look for.

When all 4 steps are complete, nothing further needs to be done. When vampires attack your village, settlement, city, or whatever, the NPCs will flee.

Where they go depends on a few things:

A. If they are already indoors, they will be made to stay there for the duration of the attack.
B. If they are outside and have a home in the city that is marked as LocTypeDwelling, they will go there.
C. If the city has an inn, any non-resident or NPCs who live outdoors will go there.
D. If none of the above are true, the game will select a random interior from your area matching the LocTypeDwelling keyword and the NPCs will flee there.

For example, in Solitude, the city has an inn. Any NPCs in the area who don't have a home flee there consistently.

In a place like Darkwater Crossing, where there is no inn, the NPCs have two choices. Either the mine or the one house. More often than not, the game would choose the mine.

Licensing and Legal
===================

Redistribution is strictly forbidden without prior consent. This means do not upload it anywhere unless you have obtained permission from me.

Non-English translation versions may be uploaded without permission on the following conditions:

1. All mod files contained in this archive are retained with their current names.
2. No alterations are made to the contents of the plugins or master file other than those necessary to translate the English text.
3. No alterations or additions are made to the meshes and textures other than those necessary to translate English text.
4. This readme is included, in ENGLISH, exactly as it is written in the version it was downloaded with.

All inquiries regarding this mod must be directed to me. If after 180 days contact cannot be established or you have not received a response, stewardship of this mod will fall to the community at TES Alliance (tesalliance.org). I can be contacted via PM at Bethesda Game Studios Forums, TES Alliance, TES Nexus, Great House Fliggerty, Dark Creations, and AFK Mods under the username Arthmoor. I can also be contacted via my blog at http://www.iguanadons.net using the contact form there. A good faith effort must be made before assuming that contact cannot be established before concluding that I am no longer maintaining this mod.

Mod history archives such as Morrowind Mod History are permitted to keep a copy of this mod within their archives for historical purposes provided all authorship and credit information is retained and the contents of the mod are not altered in any way.

Version History
===============

Version 2.0
-----------

Complete system overhaul borrowing heavily from the new code that powers Run For Your Lives. This became necessary in order to avoid a major conflict with new logic added by the UDGP to block vampire attacks when certain quests are running. The updated code consolidates the 7 attack handlers down to one quest, eliminating many redundant scripts, quests, and AI packs.
Synchronized necessary changes from UDGP 2.0.4.
If the protection quest is unable to start after 60 seconds, the mod will terminate the vampire attack rather than allowing it to proceed.
All edits to Dawnguard quest records have been removed. Affected quests and scripts will return to their original states.

Version 1.1.2
-------------

Added a condition check to the aliases to make sure they only fill with unique actors. This should eliminate accidentally picking up nearby hunters or other leveled list NPCs that shouldn't be getting dragged in.
The check for child location status of an NPC's editor location was backward. This resulted in every NPC in an affected target area trying to cram into the inn instead of going to their houses like they were supposed to.
When a citizen alias is filled, the AI pack will call for them to stop all combat activity prior to sending them to their safe harbor location. This should reduce the number of wannabe heroes.
In the event a citizen STILL decides to play hero, as long as they are protected by essential status, entering bleedout will result in them being instantly healed for up to 75 health so as to avoid a possible scenario where the NPC could die if the vampires were killed while they're bleeding out.

Version 1.1.1
-------------

If the disguised "traveler" vampire who attacks cities is attacked, but the player leaves without killing him, the quest that sends the NPCs into hiding does not stop. (Bug #14377)
Had to reimplement the fix for dogs being at the stables instead of inside the city with the vampires.

Version 1.1
-----------

The protection system has been broken down into individual events so that when a city is attacked by more than one type of event the quest will not prematurely shut down and put the NPCs in danger again.

Version 1.0.3
-------------

Vampire attacks in Solitude, Whiterun, and Windhelm should no longer result in vampires or their thralls and death hounds lurking about near the stables, causing the player to believe the attack on the city was over when it really wasn't. (Bug #6)
NPCs who are marked as being ghosts will no longer be subject to filling a protected alias. Helgi in Morthal is one example of this.

Version 1.0.2
-------------

Corrected the monitoring quest to count a broken alias as a dead vampire. While this may lead to false positives on one being dead, it prevents a situation where the attack quest might remain running longer than necessary and cause AI disruption.
The cultists from Dragonborn should no longer be caught in the safety net. dunPrisonerFaction is now considered exempt, which the cultists are a member of.
Fixed a bug where the protection quest would terminate too early due to an error in checking the number of dead vampires against the total.
Fixed a bug where multiple detection events could pile up and lead to script overload, and potential CTDs.

Version 1.0.1
-------------

Found and removed some rogue data which could have prevented the protection quest from launching.
Corrected a packaging error from having archived the wrong ESP, which was leading to errors being thrown about a missing script that isn't supposed to exist anymore.

Version 1.0
-----------

Initial release.